import java.util.Scanner;


public class ZsxgZuoye {
   public static void main(String[] args) {
	        	Scanner input	= new Scanner(System.in);
	        	boolean flag = true;
				// 数组增删改查
	        	int  [] shu = {22,88,33,66,0,0};
	        	do{
	        	System.out.println("\n----------选择列表---------");
	        	System.out.println("\t1,增加数据");
	        	System.out.println("\t2,删除数据");
	        	System.out.println("\t3,修改数据");
	        	System.out.println("\t4,查找数据");
	        	System.out.println("\t5,数据列表");
	        	System.out.println("\t6,退        出");
	        	
	        	System.out.println("请输入你的选择：");
	        	int xuanZe = input.nextInt();
	        	
	        	switch (xuanZe){
	        	  case 1:
	        		  int xia = -1;
	        		  System.out.print("请输入你要增加的数：");
	        		  int zeng = input.nextInt();
	        		  for(int i=0;i<shu.length;i++){
	        			  if(shu[i]==0){
	        				  xia = i;
	        				  break;
	        			  }
	        		  }
	        		  if(xia != -1){
	        			 shu[xia] =zeng;
	        			 for(int xinZ :shu){
	           			  System.out.print("添加成功，值是："+xinZ+"\t");
	           		  }
	        		 }else{
	        			 System.out.println("数组已经满了");
	        		 }
	        		  
	        		  break;
	        	  case 2:
	        		  int xia1 = -1;
	        		  System.out.print("请输入你要删除的数：");
	        		  int shan = input.nextInt();
	        		  for(int i=0;i<shu.length;i++){
	        			  if(shu[i]==shan){
	        				  xia1 = i;
	        				  break;
	        			  }
	        		  }
	        		  if(xia1 != -1){
	        			  for(int j=xia1;j<shu.length-1;j++){
	        				  shu[j]=shu[j+1];
	        			  }
	        			  shu[shu.length-1]=0;
	        			  for(int xinS :shu){
	               			  System.out.print("删除成功，值是："+xinS+"\t"); 
	               			  }
	        		  }else{
	        			  System.out.println("没有要删除的数");
	        		  }
	        		  break;
	        	  case 3:
	        		  int xia2 =-1;
	        		  System.out.println("输入你要修改的数");
	        		  int xiu = input.nextInt();
	        		   for(int i=0;i<shu.length;i++){
	        			   if(shu[i]==xiu){
	        				   xia2 =i;
	        				   break;
	        			   }
	        		   }
	        		   if(xia2 !=-1){
	        			   System.out.println("请输入修改后的数");
	        			   int gai  =input.nextInt();
	        			   shu[xia2]=gai;
	        			   for(int xinX :shu){
	                			  System.out.print("修改成功，值是："+xinX+"\t"); 
	                			  }
	         		  }else{
	         			  System.out.println("修改失败");
	         		  }
	        		   
	        		  break;
	        	  case 4:
	        		  int xia3 =-1;
	        		  System.out.println("输入你要查找的数");
	        		  int cha = input.nextInt();
	        		   for(int i=0;i<shu.length;i++){
	        			   if(shu[i]==cha){
	        				   xia3 =i;
	        				   break;
	        			   }
	        		   }
	        		   if(xia3 !=-1){
	        			  shu[xia3]=cha;
	        			 System.out.println("恭喜你查有此数据"); 
	        		   }else{
	        			   System.out.println("查无此数据");
	        		   }
	        		  break;
	        	  case 5:
	        		  System.out.println("\t数据展示\n");
	        		  for(int zhan :shu){
	        		  if(zhan !=0){
	        			  System.out.println("----  "+zhan+"  ----");
	        		  }}
	        		  break;
	        	  case 6:
	        		  System.out.println("是否退出(Y/N)");
	        		  String tui =input.next();
	        		  if(tui.equals("Y")){
	        			  flag = false;
	        			  break;
	        		  }
	        		  break;
	        	  default:
	        		  System.out.println("你的输入有误重新输入");
	        		  break;
	        	}
	        	}while(flag);
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
	        	
			}
	}


